/*
 * Copyright (C) 2012 JiangHongTiao
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package sk.lieskove.jianghongtiao.paris.core.classify;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.log4j.Logger;
import sk.lieskove.jianghongtiao.common.utils.PropertiesUtils;

/**
 * 
 * @author xjuraj e-mail: jjurco.sk_gmail.com
 */
public class JoinDocumentClasses implements Serializable {
    
    private transient Logger log = Logger.getLogger(JoinDocumentClasses.class);
    private transient PropertiesUtils pu = new PropertiesUtils(JoinDocumentClasses.class);
    
    private String joinString;
    private List<String> joinClasses;
    private String resultClass;

    public JoinDocumentClasses(String joinString) {
        this.joinString = joinString;
        parseString(joinString);
    }
    
    private void parseString(String joinString){
        String[] split = joinString.split("=>");
        if((split.length > 2) || (split.length == 0)){
            throw new IllegalArgumentException("Join string is not in format: "
                    + "<class>,...,<class>=><JoinClass> or <class>,...,<class>");
        }
        joinClasses = new ArrayList<String>(Arrays.asList(split[0].split(",")));
        if(split.length == 2){
            resultClass = split[1];
        } else {
            resultClass = "-";
            for (String jClass : joinClasses) {
                resultClass+=jClass+"-";
            }
        }
    }

    public List<String> getJoinClasses() {
        return joinClasses;
    }

    public void setJoinClasses(List<String> joinClasses) {
        this.joinClasses = joinClasses;
    }

    public String getJoinString() {
        return joinString;
    }

    public void setJoinString(String joinString) {
        this.joinString = joinString;
    }

    public String getResultClass() {
        return resultClass;
    }

    public void setResultClass(String resultClass) {
        this.resultClass = resultClass;
    }
    
    
}
